/** This Code is automatically generated
*
* @author Cleverson Carneiro Trevenzoli
* @author Vladimir Oliveira Di Iorio
*/

public class AspectInfoContains extends abc.weaving.aspectinfo.Pointcut {
Pointcut param =
  null;
public AspectInfoContains(Position pos,
                          Pointcut param) {
    super(pos);
    this/*null*/.param =
      param;
}
public void getFreeVars(Set result) {
    
}
public void registerSetupAdvice(Aspect context,
                                Hashtable typeEnv) {
    
}
public Pointcut inline(Hashtable renameEnv,
                       Hashtable typeEnv,
                       Aspect context,
                       int cflowdepth) {
    Pointcut newParam =
      param.inline(renameEnv,
                   typeEnv,
                   context,
                   cflowdepth);
    if (newParam ==
          param) {
        return this;
    }
    return new AspectInfoContains(getPosition(),
                                  newParam);
}
public String toString() {
    return "contains(" +
             param.toString() +
      ")";
}
public Residue matchesAt(MatchingContext mc)
      throws SemanticException {
    Residue ret =
      NeverMatch.v();
    if (!(mc.getShadowMatch() instanceof BodyShadowMatch)) {
        return NeverMatch.v();
    }
    Chain stmtsChain =
      mc.getSootMethod().getActiveBody().getUnits();
    Stmt current;
    Stmt next;
    for (current =
           (Stmt)
             stmtsChain.getFirst();
         current !=
           null;
         current =
           next) {
        next =
          (Stmt)
            stmtsChain.getSuccOf(current);
        StmtMethodPosition pos =
          new StmtMethodPosition(mc.getSootMethod(),
                                 current);
        NewStmtMethodPosition newPos =
          new NewStmtMethodPosition(mc.getSootMethod(),
                                    current,
                                    next);
        if (doShadows(mc,
                      pos) ==
              AlwaysMatch.v() ||
              doShadows(mc,
                        newPos) ==
                AlwaysMatch.v()) {
            ret =
              AlwaysMatch.v();
            break;
        }
    }
    return ret;
}
public Residue doShadows(MatchingContext mc,
                         MethodPosition pos)
      throws SemanticException {
    Residue ret =
      NeverMatch.v();
    for (Iterator i =
           abc.main.Main.v().getAbcExtension().shadowTypes();
         i.hasNext();
         ) {
        ShadowType st =
          (ShadowType)
            i.next();
        ShadowMatch sm;
        try {
            sm =
              st.matchesAt(pos);
        }
        catch (InternalCompilerError e) {
            throw new InternalCompilerError(e.message(),
                                            e.position() ==
                                              null ? abc.polyglot.util.ErrorInfoFactory.getPosition(pos.getContainer(),
                                                                                                    pos.getHost()) : e.position(),
                                            e.getCause());
        }
        catch (Throwable e) {
            throw new InternalCompilerError("Error while looking for join point shadow",
                                            abc.polyglot.util.ErrorInfoFactory.getPosition(pos.getContainer(),
                                                                                           pos.getHost()),
                                            e);
        }
        Residue currMatch =
          param.matchesAt(new MatchingContext(mc.getWeavingEnv(),
                                              mc.getSootClass(),
                                              mc.getSootMethod(),
                                              sm));
        if (currMatch ==
              AlwaysMatch.v()) {
            ret =
              currMatch;
            break;
        }
    }
    assert ret ==
             AlwaysMatch.v() ||
      ret ==
        NeverMatch.v(): "Error: Dynamic match on contains() parameter";
    return ret;
}
public AspectInfoContains(polyglot.util.Position pos) {
super(pos);
}

}